import request from 'src/utils/request'
import { rsaEncrypt } from 'src/crypto/Crypto'

export function captcha() {
    return request({
        url: '/auth/pwd/captcha',
        method: 'get'
    })
}

// login 用户登录请求
export function login(data) {
    const params = Object.assign({}, data)
    params.password = rsaEncrypt(params.password)
    return request({
        url: '/auth/pwd/login',
        method: 'post',
        data: params
    })
}

// getInfo 获取用户信息 权限菜单
export function getInfo(token) {
    return request({
        url: '/auth/init/info',
        method: 'post',
        params: { }
    })
}

export function logout() {
    return request({
        url: '/auth/logout',
        method: 'post'
    })
}

// getWechatQRCode 获取微信登录二维码图片
export function getWechatQRCode(data) {
    return request({
        url: '/wx/open/createQrCode',
        method: 'post',
        data
    })
}

// wechatLogin 微信登录
export function wechatLogin(data) {
    return request({
        url: '/wx/open/checkLogin',
        method: 'post',
        data
    })
}

// 修改密码
export function changePassword(data) {
    return request({
        url: '/system/user/changePassword',
        method: 'post',
        data
    })
}

// 重置密码
export function resetpwd(data) {
    return request({
        url: '/system/user/resetpwd',
        method: 'post',
        data
    })
}

// 获取websocket地址
export function getWebsocketUrl(data) {
    return request({
        url: '/system/user/getWebsocketUrl',
        method: 'post',
        data
    })
}

// 根据用户id查询所有类型短信余量
export function walletInfoByUserId(data) {
    return request({
        url: '/sms/wallet/walletInfoByUserId',
        method: 'post',
        data
    })
}

// 根据类型获取用户的短信余量
export function getSmsCountByType(data) {
    return request({
        url: '/sms/wallet/getSmsCountByType',
        method: 'post',
        data
    })
}

// 短信划拨
export function smsTransfer(data) {
    return request({
        url: '/sms/wallet/smsTransfer',
        method: 'post',
        data
    })
}

// 获取微信绑定二维码
export function createWxBindQrCode(data) {
    return request({
        url: '/wx/auth/createWxBindQrCode',
        method: 'post',
        data
    })
}

// 查询扫码状态
export function checkAccountBindState(data) {
    return request({
        url: '/wx/user/checkAccountBindState',
        method: 'post',
        data
    })
}

// 绑定微信
export function bindAccount(data) {
    return request({
        url: '/wx/user/bindAccount',
        method: 'post',
        data
    })
}

// 重置子账号密码
export function resetpwdSub(data) {
    return request({
        url: '/system/user/resetpwdSub',
        method: 'post',
        data
    })
}

// 添加子账号
export function addSub(data) {
    return request({
        url: '/system/user/addSub',
        method: 'post',
        data
    })
}

// 禁用
export function close(data) {
    return request({
        url: '/system/user/close',
        method: 'post',
        data
    })
}

// 启用
export function open(data) {
    return request({
        url: '/system/user/open',
        method: 'post',
        data
    })
}

// 检查是否绑定
export function wxBindStateByUserId(data) {
    return request({
        url: '/wx/user/wxBindStateByUserId',
        method: 'post',
        data
    })
}

